home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / ToolTips.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  2.0 KB  |  85 lines

  1. --
  2. -- This file describes the tool tip commands used for the menus
  3. -- 
  4.  
  5. function KillToolTipsPopup()
  6.     if( not( ToolTipsWindow == nil ) and ToolTipsWindow.IsValid() ) then
  7.         ToolTipsWindow.Destroy();
  8.     end
  9. end
  10.  
  11. function ToolTipsPopup( text )
  12.     if( ToolTipsWindow == nil or not(ToolTipsWindow.IsValid()) ) then
  13.         G.Create( "MenuData/ToolTipsTextCog.xml" );
  14.     end
  15.     
  16.     -- Make it slightly offset from the cursor
  17.     local x = G.GetMouseX()
  18.     
  19.     if( x < 0.5 ) then
  20.         x = x + 0.26
  21.     else
  22.         x = x - 0.26
  23.     end
  24.     
  25.     local y = G.GetMouseY()
  26.     
  27.     if( y < 0.25 ) then
  28.         y = y + 0.26
  29.     else
  30.         y = y - 0.26
  31.     end
  32.     
  33.     ToolTipsWindow.SetGuiPosition( "ToolTipsTextBox", Vector3( x, y, 0 ) ) 
  34.     ToolTipsWindow.SetGuiText( "ToolTipsTextBox", text, 0 );
  35.  
  36. --    TextFadeTime = TotalTextDur
  37. end
  38.  
  39.  
  40. prevToolTipObj = ""
  41. ToolTipShowDelay = 1.75
  42. ToolTipTimer = 0
  43.  
  44. function UpdateToolTip()
  45.     
  46.     -- Check what object the cursor is hovering over:
  47.     if( not( GuiObjectOver == prevToolTipObj ) ) then
  48.         -- if DIFFERENT hide the current text, update the text, reset the timer
  49.         KillToolTipsPopup()
  50.         prevToolTipObj = GuiObjectOver
  51.         ToolTipTimer = 0;
  52.     else
  53.         -- else increase the timer
  54.         ToolTipTimer = ToolTipTimer + GameTimeDiff
  55.     end
  56.     
  57.     -- 
  58.     if( ToolTipTimer > ToolTipShowDelay ) then
  59.         -- If the timer is over the mininum, set the text visible:
  60.         -- Sadly, you don't now who's this is, just check Traitor, MainMenu & HUD
  61.         local descText = ""
  62.         if( not( MainMenu == nil ) and MainMenu.IsValid() ) then
  63.             descText = MainMenu.GetDescription( prevToolTipObj );
  64.         end
  65.         
  66.         if( descText == "" and not( HUD == nil ) and HUD.IsValid() ) then
  67.             descText = HUD.GetDescription( prevToolTipObj );
  68.         end
  69.         
  70.         if( descText == "" and not( Traitor == nil ) and Traitor.IsValid() ) then
  71.             descText = Traitor.GetDescription( prevToolTipObj );
  72.         end
  73.         
  74.         if( not(descText == "") ) then
  75.             ToolTipsPopup( descText )
  76.         end
  77.         
  78.         -- Some tips are special (Traps, TowerHP) So they need special code:
  79.     end
  80.     
  81. end
  82.  
  83. GMain[ "UpdateToolTip" ] = UpdateToolTip;
  84.  
  85.